package com.oig.sys.log;

import com.oig.sys.log.aspect.SysLogAspect;
import com.oig.sys.log.event.SysAuditLogEventListener;
import com.oig.sys.log.event.SysLogEventListener;
import com.oig.sys.log.feign.SysAuditLogService;
import com.oig.sys.log.feign.SysLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;


@EnableAsync
@RequiredArgsConstructor
@ConditionalOnWebApplication
@Configuration(proxyBeanMethods = false)
public class LogAutoConfiguration {

    private final SysLogService sysLogService;
    private final SysAuditLogService sysAuditLogService;

    @Bean
    public SysLogEventListener sysLogEventListener() {
        return new SysLogEventListener(sysLogService);
    }

    @Bean
    public SysAuditLogEventListener sysAuditLogEventListener(){
        return new SysAuditLogEventListener(sysAuditLogService);
    }

    @Bean
    public SysLogAspect sysLogAspect() {
        return new SysLogAspect();
    }

}
